import requests
import re
import concurrent.futures
import time


def get_data(uel):
    resp = requests.get(uel)
    return resp


def jiexi(resp):
    img_url_list = re.findall('<img class="ui image lazy" data-original="(.*?)"', resp)
    return img_url_list


def baocun(img_url_list):
    for img_url in img_url_list:
        name = img_url.split('/')[-1]
        with open(f'img2\\{name}', mode='wb') as f:
            f.write(get_data(img_url).content)
            print(f'{name}下载成功！！！！')


def main():
    for page in range(1, 51):
        url = f'https://www.fabiaoqing.com/biaoqing/lists/page/{page}.html'
        resp = get_data(url).text
        img_url_list = jiexi(resp)
        baocun(img_url_list)
    new = time.time()
    print(new - old)


old = time.time()
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as exe:
    exe.submit(main)
